## Makefile
##
## Copyright 2006, Brian Swetland.  All rights reserved.
## See provided LICENSE file or http://frotz.net/LICENSE for details.
##

CC      := arm-elf-gcc
OBJCOPY := arm-elf-objcopy
OBJDUMP := arm-elf-objdump

vpath %.c ../library
vpath %.S ../library

CFLAGS  := -O2 -g -Wall -I. -I../library
CFLAGS  += -DUSB_VENDOR=0x4242 -DUSB_PRODUCT=0x0002 -DWITH_FASTER_USB=1

#ASFLAGS += -march=arm7

#CFLAGS  += -mthumb -mthumb-interwork
#ASFLAGS += -mthumb-interwork

#TARGET  := jtag
#OBJS    := crt0_ram.o clk-48mhz.o 
#OBJS    += jtag.o arm7tdmi.o main.o
#OBJS	+= debug_usb.o dprintf.o

TARGET  := debugger
OBJS    := crt0_rom.o init_clock.o usb.o
OBJS    += debugger_main.o debugger.o jtag.o 
#arm7tdmi.o

all: $(TARGET) $(TARGET).lst

$(TARGET).elf: $(OBJS)
	arm-elf-ld --script ../library/rom.ld -o $(TARGET).elf $(OBJS)

$(TARGET): $(TARGET).elf
	$(OBJCOPY) -O binary $(TARGET).elf $(TARGET)

$(TARGET).lst: $(TARGET).elf
	$(OBJDUMP) -d $(TARGET).elf > $(TARGET).lst

clean:
	rm -f *.o *~ *.elf *.lst $(TARGET) 

